<template>
    <div class="cinemalist" v-cloak>
        <myHead :title="film.name" :show="true"></myHead>
        <van-tabs     
            @change="getitem"        
            swipeable 
            animated 
            sticky >
            <van-tab v-for='(l,i) in showCinemas' :name="i" :key="i" :title="l.showDate | dateFormat('YY-MM-DD')">
                <cinemaList :dateday="showCinemas[i].showDate" :film="film" :list="list"></cinemaList>
            </van-tab>
        </van-tabs>
    </div>
</template>
<script>
export default {
    data(){
        return{
            film:{},
            showCinemas:[],
            list:[]
        }
    },
    methods:{
        getcinemasList(cinemaIds){
            // 影院列表  
            this.$ajax.postmaizuodata({
                cityId:this.cityinfo.cityId,
                cinemaIds:cinemaIds.join(",")
            },{
                'X-Host': 'mall.film-ticket.cinema.batch-cinema'
            }).then(res=>{
                if(res.code==200){
                    this.list = res.result.data.cinemas
                }
            })
        },
        getitem(name,title){
            console.log(name);
            console.log(title);
            this.getcinemasList(this.showCinemas[name].cinemaList)
        }
    },
    mounted(){
        // 电影数据
        this.$ajax.getmaizuodata({
                filmId:this.$route.params.filmId
        },{
            'X-Host': 'mall.film-ticket.film.info'
        })
        .then(res=>{
            if(res.code==200){
                this.film = res.result.data.film
            }
        })
        // 电影时间
        this.$ajax.getmaizuodata({
                filmId:this.$route.params.filmId,
                cityId:this.cityinfo.cityId,
        },{
            'X-Host': 'mall.film-ticket.cinema.film-show-cinema'
        })
        .then(res=>{
            if(res.code==200){
                this.showCinemas = res.result.data.showCinemas;
                this.getcinemasList(this.showCinemas[0].cinemaList);
            }
        })
    }
}
</script>